/**
 * Copyright (C) 2006 OQube 
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *  
 * author: Arnaud Bailly - abailly AT oqube DOT com
 * created: 14 juin 2006
 */
package speculoos.jndi.mappers;

import java.util.Map;

/**
 * A special variable that creates an array of String representing allowed
 * returning attributes in a query from a map.
 * 
 * @author nono
 * 
 */
public class ReturningAttributesVariable extends ObjectVariable {

	/*
	 * (non-Javadoc)
	 * 
	 * @see speculoos.jndi.mappers.ObjectVariable#getName()
	 */
	public String getName() {
		return "ReturningAttributesVariable";
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see speculoos.jndi.mappers.ObjectVariable#getReference()
	 */
	public String getReference() {
		return "returningAttributes";
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see speculoos.jndi.mappers.ObjectVariable#setReference(java.lang.String)
	 */
	public void setReference(String reference) {
		// NOP
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see speculoos.jndi.mappers.ObjectVariable#setValue(java.lang.Object)
	 */
	public void setValue(Object value) {
		Map m = (Map) value;
		String[] sa = new String[m.size()];
		super.setValue((String[]) m.keySet().toArray(sa));
	}

}
